<template>
  <div class="bgc-default pad-t-10">
    <div class="bg-color-white pad-10">
      <div class="tabs-box mar-t--10" v-if="showStatOrder">
        <el-tabs v-model="orderStatus" @tab-click="doChangeTab">
          <el-tab-pane :label="labels[1]" name="1"> </el-tab-pane>
          <el-tab-pane :label="labels[20]" name="20"> </el-tab-pane>
          <el-tab-pane :label="labels[2]" name="2"> </el-tab-pane>
          <el-tab-pane :label="labels[3]" name="3"> </el-tab-pane>
          <el-tab-pane :label="labels[0]" name="0"> </el-tab-pane>
          <el-tab-pane :label="labels[4]" name="4"></el-tab-pane>
          <el-tab-pane :label="labels[-2]" name="-2"> </el-tab-pane>
          <el-tab-pane :label="labels[100]" name="100"></el-tab-pane>
        </el-tabs>
      </div>
      <div v-if="getVersionType() == 5" class="div-style-2 font-16 mar-b-15">
        <p class="font-18"><b>生成配送单说明</b></p>
        <p>第一步：点击<span class="blue">生成配送单</span>按钮后系统会“根据截单时间”或将“当前查询条件下”的待配送订单自动生成配送单。</p>
        <p>第二步：进入配送单管理页，点击<span class="blue">确认配送</span>按钮。</p>
      </div>
      <!--顶部搜索 -->
      <div id="topSearch" class="top-operate-default flex-col"
        style="align-items: baseline; padding: 20px 0; height: 100%; ">
        <div class="search-item">
          <label>搜索订单：</label>
          <el-select v-model="textCol">
            <el-option label="订单号" value="orderNo"></el-option>
            <el-option label="收货人" value="customerNickname"></el-option>
            <el-option label="收货人电话" value="customerPhone"></el-option>
            <el-option label="商品名称" value="goodsTitle"></el-option>
            <el-option :label="getVersionType() == 5 ? '团长名称' : '分销商名称'" value="memberNickname"></el-option>
            <el-option :label="getVersionType() == 5 ? '团长电话' : '分销商电话'" value="memberPhone"></el-option>
            <el-option label="来源订单号" value="sellApartOrderNo"></el-option>
            <el-option label="来源企业" value="supplyAllianceEnterpriseName"></el-option>
          </el-select>
          <el-input v-model="textValue" placeholder="请输入内容" style="width: 200px"></el-input>
          <label class="mar-l-20">时间筛选：</label>
          <el-select class="pad-l-10" v-model="timeCol">
            <el-option label="下单时间" value="createTime"></el-option>
            <el-option label="付款时间" value="payTime"></el-option>
            <el-option label="发货时间" value="deliveryTime"></el-option>
            <el-option :label="getVersionType() == 5 ? '提货时间' : '收货时间'" value="receivedTime"></el-option>
            <el-option label="取消时间" value="cancelTime"></el-option>
            <el-option label="完成时间" value="completeTime"></el-option>
          </el-select>
          <el-date-picker v-model="timeValue" type="datetimerange" range-separator="至"
            value-format="yyyy-MM-dd HH:mm:ss" :default-time="['00:00:00', '23:59:59']" start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
          <el-autocomplete v-model="defaultQuery.memberVillageId" class="inline-input" :fetch-suggestions="queryVillage"
            placeholder="请选择/输入小区名称" @select="onSelectVillage" @input="onClearVillage" v-if="getVersionType() == 5">
          </el-autocomplete>
          <el-select v-model="defaultQuery.apartOrderSource" placeholder="订单发货方" clearable class="mar-l-10 cus-select">
            <el-option label="全部订单发货方" value=""></el-option>
            <el-option label="企业发货" value="10"></el-option>
            <el-option label="供应商发货" value="20"></el-option>
            <el-option label="供货联盟" value="40"></el-option>
          </el-select>
        </div>
        <div class="search-item mar-t-10">
          <el-select v-model="defaultQuery.sampleFlag" placeholder="寄样订单" clearable class="cus-select">
            <el-option label="全部" value=""></el-option>
            <el-option label="非寄样订单" value="0"></el-option>
            <el-option label="寄样订单" value="1"></el-option>
          </el-select>
          <template v-if="enterpriseConfig.storeHomeAuthority * 1 === 1">
            <el-select v-model="defaultQuery.deliveryMode" placeholder="请选择" class="mar-l-10 cus-select">
              <el-option v-for="item in storeOptions" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </template>
          <el-select v-model="defaultQuery.isSupplyAllianceOrder" placeholder="订单来源" clearable
            class="mar-l-10 cus-select">
            <el-option label="全部订单来源" value=""></el-option>
            <el-option label="企业订单" value="0"></el-option>
            <el-option label="供货联盟订单" value="1"></el-option>
          </el-select>
          <el-button-group class="mar-l-20">
            <el-button type="primary" @click="doSearch">查询</el-button>
            <el-button @click="doResetSearch">重置</el-button>
          </el-button-group>
        </div>
      </div>
      <!-- 全选、操作 -->
      <div class="pad-t-15 pad-b-15 font-14 v-align-c">
        <el-checkbox class="mar-l-14 mar-r-0" v-model="allChecked" @change="selectAll">
          <span class="mar-l-20">当页全选</span>
        </el-checkbox>
        <span class="pad-l-4 pad-r-4">|</span>
        <div class="width-80">已选{{multipleSelection.length}}项</div>
        <el-button v-if="getVersionType() == 5 && orderStatus == 1" @click="generateDelivery">生成配送单</el-button>
        <el-button @click="exportOrder">批量导出</el-button>
         <el-button v-if="orderStatus == 1 || orderStatus == 20" @click="doBatchGenerateSend">批量生成发货单</el-button>
      </div>
      <!-- 内容列表 -->
      <div class="table-container" style="height: 100%; ">
        <el-table ref="multipleTable" :data="dataList" @selection-change="handleSelectionChange" v-loading="listLoading"
          element-loading-text="加载中">
          <el-table-column width="50px" type="selection"></el-table-column>
          <el-table-column width="280px" label="订单信息" fixed="left">
            <template slot-scope="scope">
              <div class="flex v-align-c cursor-p" @click="doLinkDetail(scope.row)">
                <label v-if="scope.row.goodsImageUrl"><img :src="scope.row.goodsImageUrl"
                    class="user-avatar cursor-p"></label>
                <div class="font-14 pad-l-10">
                  <div class="line-2">
                    <template v-if="scope.row.sampleFlag == 1">
                      <el-tag size="mini" type="warning" effect="light">寄样</el-tag>
                    </template>
                    <template v-if="scope.row.goodsTitle" class="goods-title">
                      <span>{{ scope.row.goodsTitle }}</span>
                    </template>
                  </div>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column width="220px" label="订单号" align="center" prop="orderNo">
            <template slot-scope="scope">
              <span>{{scope.row.orderNo}}</span>
              <div v-if="scope.row.sellApartOrderId != null">
                来源：{{scope.row.sellApartOrderNo}}
              </div>
            </template>
          </el-table-column>
          <el-table-column width="80px" label="售后状态" align="center">
            <template slot-scope="scope">
              <div>
                <template v-if="scope.row.afterSaleFlag == 0">
                  <span class="font-color">{{dict.afterSaleFlag[scope.row.afterSaleFlag]}}</span>
                </template>
                <template v-else>
                  <span v-if="scope.row.orderNo" class="font-red cursor-p"
                    @click="doLinkAfter(scope.row)">{{dict.afterSaleFlag[scope.row.afterSaleFlag]}}</span>
                  <span v-else class="font-red">{{dict.afterSaleFlag[scope.row.afterSaleFlag]}}</span>
                </template>
              </div>
            </template>
          </el-table-column>
          <el-table-column width="200px" label="订单来源" align="center" prop="sellApartOrderId">
            <template slot-scope="scope">
              <span v-if="scope.row.sellApartOrderId != null">
                <span>供货联盟订单</span>
                <div>{{scope.row.supplyAllianceEnterpriseName}}</div>
              </span>
              <span v-else>企业订单</span>
            </template>
          </el-table-column>
          <el-table-column width="180px" label="收货人">
            <template slot-scope="scope">
              <div v-if="scope.row.customerNickname">
                <div>{{scope.row.customerNickname}}</div>
                <div v-if="scope.row.customerPhone">{{scope.row.customerPhone}}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column width="120px" label="数量" prop="goodsNum">
          </el-table-column>
          <el-table-column width="150px" label="实付金额" prop="actualPrice" v-if="getVersionType() != 2">
            <template slot-scope="scope">
              <div v-if="scope.row.actualPrice">
                <div>￥{{scope.row.actualPrice}}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column width="150px" label="实收金额" prop="enterpriseAmount" v-if="getVersionType() != 2">
            <template slot-scope="scope">
              <div v-if="scope.row.enterpriseAmount">
                <div>￥{{scope.row.enterpriseAmount}}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column width="200px">
            <template slot="header" slot-scope="scope">
              <span>{{orderTimeColName}}</span>
            </template>
            <template slot-scope="scope">
              {{ scope.row[orderTimeCol]}}
            </template>
          </el-table-column>
          <el-table-column width="150px" label="订单状态" v-if="orderStatus == 100 || orderStatus == 11">
            <template slot-scope="scope">
              {{ getVersionType() == 5 ? dict.villageOrderStatus[scope.row.orderStatus] : dict.orderStatus[scope.row.orderStatus] }}
            </template>
          </el-table-column>
          <el-table-column width="120px" label="包裹数量" prop="packageNum" v-if="orderStatus != 11">
          </el-table-column>
          <el-table-column width="100px" label="操作" align="right" fixed="right">
            <template slot-scope="scope">
              <el-button type="text" size="medium" class="table-btn" @click="doLinkDetail(scope.row)">查看详情
              </el-button>
              <template v-if="!warehouseDeliverFlag">
                <el-button type="text" size="medium" class="table-btn" v-if="scope.row.enterpriseDeliveryFlag == 1"
                  @click="doOpenDeliver(scope.row)">发货
                </el-button>
              </template>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!-- 列表分页 -->
      <div class="pagination">
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
          :current-page="searchListQuery.currentPage" :page-sizes="[10, 20, 50, 100]" :page-size="searchListQuery.size"
          layout="total, sizes, prev, pager, next, jumper" :total="total">
        </el-pagination>
      </div>
    </div>

    <!-- 发货单管理dialog -->
    <el-dialog width="1200px" v-el-drag-dialog title="发货单管理" :visible.sync="orderDeliverVisible" :show-close="false">
      <order-send-manage :showFlag="orderDeliverVisible" :apartOrderId="selectApartOrderId"
        @callback="doCallbackOrderDeliver">
      </order-send-manage>
    </el-dialog>

  </div>
</template>

<script>
  import {
    pageProjectOrder,
    statProjectOrder
  } from '@/api/goods/order'
  import {
    getByEnterpriseId
  } from '@/api/user/enterprise'
  import {
    doGenerateDelivery
  } from '@/api/goods/delivery'
  import {
    listVillageByEnterpriseId
  } from '@/api/user/village'
  import {
    downloadFile
  } from '@/api/common/common'
  import elDragDialog from '@/directive/el-dragDialog'
  import orderSendManage from '@/views/goods/order/components/order-send-manage'

  export default {
    components: {
      orderSendManage
    },
    directives: {
      elDragDialog
    },
    watch: {
      // 监听屏幕高度改变表格高度
      screenHeight(val) {
        this.topSearchHeight()
      }
    },
    data() {
      return {
        storeOptions: [{
          value: 'allDeliveryModel',
          label: '全部配送方式'
        }, {
          value: 'homeDelivery',
          label: '配送到家'
        }, {
          value: 'storeExtraction',
          label: '门店自提'
        }, {
          value: 'logisticsExpress',
          label: '物流快递'
        }],
        enterpriseConfig: {},
        // 文本model
        textCol: 'orderNo',
        textValue: '',
        // 时间model
        timeCol: 'createTime',
        timeValue: [],
        // tab model
        orderStatus: '1',
        // 截停状态
        stopStatus: '0',
        // 默认查询条件
        defaultQuery: {
          currentPage: 1,
          size: 10,
          enterpriseId: '',
          orderType: 30,
          memberVillageId: '',
          batchPrintStatus: '',
          apartOrderSource: '',
          sampleFlag: '',
          deliveryMode: 'allDeliveryModel',
          isSupplyAllianceOrder: ''
        },
        promotionId: '',
        recruiterId: '',
        memberId: '',
        // 查询条件
        searchListQuery: {},
        // 数据字典
        dict: {
          orderStatus: {},
          villageOrderStatus: {}
        },
        // 仓库发货flag
        warehouseDeliverFlag: false,
        // 订单发货visible
        orderDeliverVisible: false,
        total: 0,
        listLoading: true,
        dataList: [],
        labels: {
          '0': '待付款(0)',
          '1': '待发货(0)',
          '20': '部分发货(0)',
          '2': '待收货(0)',
          '3': '已收货(0)',
          '4': '已完成(0)',
          '-2': '已取消(0)',
          '100': '全部订单(0)'
        },
        villageList: [],
        orderTimeColName: '时间',
        orderTimeColNames: {
          '0': '下单时间',
          '1': '支付时间',
          '2': '发货时间',
          '4': '完成时间'
        },
        orderTimeCol: 'createTime',
        orderTimeCols: {
          '0': 'createTime',
          '1': 'payTime',
          '2': 'deliveryTime',
          '4': 'completeTime'
        },
        showStatOrder: 1,
        allChecked: false,
        multipleSelection: [],
        // 选择订单id
        selectApartOrderId: '',
        // 当前表格高度
        screenHeight: document.body.clientHeight,
        // 设置表格高度
        tableHeight: null
      }
    },
    // 初始化页面
    created() {
      const queryParams = this.getCurrentPage().query
      if (queryParams.promotionId) {
        this.promotionId = queryParams.promotionId
      }
      if (queryParams.recruiterId) {
        this.recruiterId = queryParams.recruiterId
      }
      if (queryParams.memberId) {
        this.memberId = queryParams.memberId
      }
      if (queryParams.timeCol) {
        this.timeCol = queryParams.timeCol
      }
      if (queryParams.startEndTime) {
        this.timeValue = queryParams.startEndTime
      }
      if (queryParams.orderStatus) {
        this.orderStatus = queryParams.orderStatus
      }
      if (queryParams.stopStatus) {
        this.stopStatus = queryParams.stopStatus
      }
      if (queryParams.showStatOrder === '0') {
        this.showStatOrder = 0
      }
      getByEnterpriseId(this.getEnterpriseId()).then(response => {
        if (response.isError) return
        this.enterpriseConfig = response.data
        this.warehouseDeliverFlag = this.enterpriseConfig.warehouseAuthority === 1 && this
          .enterpriseConfig
          .warehouseDeliverFlag === 1
        if (this.getVersionType() * 1 === 5) {
          this.timeCol = 'payTime'
          const statTime = new Date()
          statTime.setHours(21)
          statTime.setMinutes(0)
          statTime.setSeconds(0)
          if (this.enterpriseConfig && this.enterpriseConfig.orderStatTime) {
            const times = this.enterpriseConfig.orderStatTime.split(':')
            statTime.setHours(times[0])
            statTime.setMinutes(times[1])
            statTime.setSeconds(times[2])
          }
          this.timeValue = [
            statTime.getFullYear() + '-' + (statTime.getMonth() + 1) + '-' + (statTime
              .getDate() - 1) + ' ' +
            statTime.getHours() + ':' + statTime.getMinutes() + ':' + statTime.getSeconds(),
            statTime.getFullYear() + '-' + (statTime.getMonth() + 1) + '-' +
            (statTime.getDate()) + ' ' + statTime.getHours() + ':' +
            statTime.getMinutes() + ':' + statTime.getSeconds()
          ]
        }
      })
      listVillageByEnterpriseId(this.getEnterpriseId()).then(response => {
        if (response.isError) return
        this.villageList = response.data
        this.villageList.forEach(village => {
          village.value = village.villageName
        })
      })
      this.searchListQuery = {
        ...this.defaultQuery
      }
      this.initList()
    },
    mounted() {
      this.topSearchHeight()
    },
    methods: {
      // 初始化
      initList() {
        this.listLoading = true
        this.setSearchListQuery()
        if (this.defaultQuery.deliveryMode === 'allDeliveryModel') {
          this.searchListQuery.deliveryTypeList = '1, 4, 5'
        } else if (this.defaultQuery.deliveryMode === 'homeDelivery') {
          this.searchListQuery.deliveryTypeList = '5'
        } else if (this.defaultQuery.deliveryMode === 'storeExtraction') {
          this.searchListQuery.deliveryTypeList = '4'
        } else if (this.defaultQuery.deliveryMode === 'logisticsExpress') {
          this.searchListQuery.deliveryTypeList = '1'
        }
        this.statOrder()
        pageProjectOrder(this.searchListQuery).then(response => {
          this.listLoading = false
          if (response.isError) return
          this.total = response.data.total
          this.dataList = response.data.records
          this.dict = response.data.dict
        })
      },
      // 统计订单
      statOrder() {
        statProjectOrder({
          enterpriseId: this.getEnterpriseId(),
          orderType: this.defaultQuery.orderType,
          recruiterId: this.recruiterId,
          memberId: this.memberId,
          crossBorderOrderType: this.searchListQuery.crossBorderOrderType,
          deliveryTypeList: this.searchListQuery.deliveryTypeList
        }).then(response => {
          if (response.isError) return
          this.labels[0] = '待付款(' + response.data[0] + ')'
          this.labels[1] = (this.getVersionType() * 1 === 5 ? '待配送' : '待发货') + '(' + response.data[
            1] + ')'
          this.labels[20] = '部分发货(' + response.data[20] + ')'
          this.labels[2] = (this.getVersionType() * 1 === 5 ? '待提货' : '待收货') + '(' + response.data[
            2] + ')'
          this.labels[3] = (this.getVersionType() * 1 === 5 ? '已提货' : '已收货') + '(' + response.data[
            3] + ')'
          this.labels[4] = '已完成(' + response.data[4] + ')'
          this.labels[100] = '全部订单(' + response.data[100] + ')'
          let cancelOrderNum = 0
          if (response.data[-1]) {
            cancelOrderNum = cancelOrderNum + response.data[-1]
          }
          if (response.data[-2]) {
            cancelOrderNum = cancelOrderNum + response.data[-2]
          }
          this.labels['-2'] = '已取消(' + cancelOrderNum + ')'
        })
      },
      // 设置查询条件
      setSearchListQuery() {
        const currentPage = this.searchListQuery.currentPage
        const size = this.searchListQuery.size
        this.searchListQuery = {
          ...this.defaultQuery
        }
        this.searchListQuery.currentPage = currentPage
        this.searchListQuery.size = size
        switch (this.orderStatus * 1) {
          default:
            this.searchListQuery.orderStatus = this.orderStatus
            this.searchListQuery.orderStatusList = ''
            break
          case -2:
            this.searchListQuery.orderStatus = ''
            this.searchListQuery.orderStatusList = '-1,-2'
            break
          case 80:
            // 招募员订单查询，不过滤订单类型orderType
            this.searchListQuery.orderStatus = ''
            this.searchListQuery.orderType = ''
            this.searchListQuery.orderStatusList = '1,2,3,4'
            break
          case 100:
            this.searchListQuery.orderStatus = ''
            this.searchListQuery.orderStatusList = ''
            break
        }
        this.searchListQuery.enterpriseId = this.getEnterpriseId()
        this.searchListQuery[this.textCol] = this.textValue
        this.searchListQuery.dateColumn = this.timeCol
        this.searchListQuery.startDate = (this.timeValue && this.timeValue.length > 0) ? this.timeValue[0] : ''
        this.searchListQuery.endDate = (this.timeValue && this.timeValue.length > 1) ? this.timeValue[1] : ''
        this.orderTimeColName = this.orderTimeColNames[this.searchListQuery.orderStatus + '']
        if (!this.orderTimeColName) {
          this.orderTimeColName = '时间'
        }
        this.orderTimeCol = this.orderTimeCols[this.searchListQuery.orderStatus + '']
        if (!this.orderTimeCol) {
          this.orderTimeCol = 'createTime'
        }
        this.searchListQuery.promotionId = this.promotionId
        this.searchListQuery.recruiterId = this.recruiterId
        this.searchListQuery.memberId = this.memberId
        this.searchListQuery.crossBorderOrderType = 1
      },
      // 查询事件
      doSearch() {
        this.searchListQuery.currentPage = 1
        this.initList()
      },
      // 重置事件
      doResetSearch() {
        const originData = this.$options.data()
        this.textCol = originData.textCol
        this.textValue = originData.textValue
        this.timeCol = originData.timeCol
        this.timeValue = originData.timeValue
        this.defaultQuery = originData.defaultQuery
        this.doSearch()
      },
      // tab切换事件
      doChangeTab() {
        this.searchListQuery.currentPage = 1
        this.initList()
      },
      // 跳转订单详情
      doLinkDetail(row) {
        this.$router.push({
          path: '/order/order/detail/index',
          query: {
            orderId: row.orderId,
            crossBorderOrderType: 1
          }
        })
      },
      // 打开发货dialog事件
      doOpenDeliver(row) {
        this.selectApartOrderId = row.apartOrderId
        this.orderDeliverVisible = true
      },
      // 订单发货回调事件
      doCallbackOrderDeliver(callbackFlag) {
        if (callbackFlag) {
          this.initList()
        }
        this.orderDeliverVisible = false
      },
      generateDelivery() {
        this.$confirm('是否将当前查询条件下的订单生成配送单？', '操作确认', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          center: true
        }).then(() => {
          const params = {
            enterpriseId: this.getEnterpriseId(),
            orderType: 30
          }
          this.setSearchListQuery()
          Object.assign(params, this.searchListQuery)
          if (this.multipleSelection.length > 0) {
            const orderIds = this.multipleSelection.map(item => item.orderId)
            params.orderIds = orderIds.join(',')
          }
          doGenerateDelivery(params).then(response => {
            if (response.isError) return
            this.$message({
              message: '操作成功！',
              type: 'success'
            })
            this.$router.push({
              path: '/order/delivery/index'
            })
          })
        }).catch(() => {})
      },
      exportOrder() {
        if (this.multipleSelection.length > 0) {
          const orderIds = this.multipleSelection.map(item => item.orderId)
          downloadFile('/goods/projectOrder/exportOrder', {
            enterpriseId: this.getEnterpriseId(),
            orderIds: orderIds.join(',')
          }, '分销订单.xlsx')
        } else {
          const params = {
            enterpriseId: this.getEnterpriseId(),
            orderType: 30
          }
          this.setSearchListQuery()
          Object.assign(params, this.searchListQuery)
          downloadFile('/goods/projectOrder/exportOrder', params, '分销订单.xlsx')
        }
      },
      onSelectVillage(item) {
        this.defaultQuery.memberVillageId = item.villageId
      },
      onClearVillage() {
        if (this.defaultQuery.memberVillageId.trim() === '') {
          // 清空小区搜索时，置空memberVillageId
          this.defaultQuery.memberVillageId = ''
        }
      },
      queryVillage(queryString, cb) {
        const results = queryString ? this.villageList.filter((village) => {
          return (village.value.toLowerCase().indexOf(queryString.toLowerCase()) >= 0)
        }) : this.villageList
        // 调用 callback 返回建议列表的数据
        cb(results)
      },
      selectAll() {
        if (this.multipleSelection.length === 0 || this.multipleSelection.length < this.dataList.length) {
          this.dataList.forEach(item => {
            this.$refs.multipleTable.toggleRowSelection(item, true)
          })
        } else {
          this.$refs.multipleTable.clearSelection()
        }
      },
      // 勾选事件
      handleSelectionChange(val) {
        this.multipleSelection = val
        if (this.multipleSelection.length === this.dataList.length) {
          this.allChecked = true
        } else {
          this.allChecked = false
        }
      },
      // 更改当前页数
      handleCurrentChange(val) {
        this.searchListQuery.currentPage = val
        this.initList()
      },
      // 更改当前页面大小
      handleSizeChange(val) {
        this.searchListQuery.size = val
        this.initList()
      },
      // 查看售后事件
      doLinkAfter(row) {
        const routeData = this.$router.resolve({
          path: '/order/after-sale/list',
          query: {
            orderNo: row.orderNo
          }
        })
        window.open(routeData.href, '_blank')
      },
      // 批量生成发货单事件
      doBatchGenerateSend() {
        if (this.multipleSelection.length <= 0) {
          this.$message({ message: '请勾选数据', type: 'warning' })
          return
        }
        const params = {
          enterpriseId: this.getEnterpriseId(),
          systemRoleType: this.getSystemRoleType(),
          orderIds: this.multipleSelection.map(item => item.orderId)
        }
        this.$bus.$emit('asyncHandle', '300003', params, () => {
          this.initList()
        })
      },
      // 自适应设置内容高度
      topSearchHeight() {
        var my_div = document.getElementById('topSearch')
        // 监听屏幕高度
        window.onresize = () => {
          return (() => {
            window.screenHeight = document.body.clientHeight
            this.screenHeight = window.screenHeight
          })()
        }
        window.topSearchHeight = window.getComputedStyle(my_div, null).getPropertyValue('height')
        var height = this.screenHeight - parseInt(window.topSearchHeight) - 275
        this.tableHeight = height + 'px'
      }
    }
  }
</script>

<style lang="less" scoped>
  .user-avatar {
    width: 65px;
    height: 65px;
    display: block;
    padding: 1px;
    border: #efefef 1px solid;
  }

  .goods-title {
    color: #155bd4;
    line-height: 1.2;
  }

  .cus-select {
    width: 160px;

    /deep/ .el-input {
      width: 160px;
    }
  }
</style>
